package com.hyc.commons.result;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnore;

/** 
 * @author  作者 Mark: 
 * @date 创建时间：2018年1月15日 上午11:05:41 
 * @version 1.0 
 * @parameter  
 * @since  
 * @return 
 */
public class PageInfo implements Serializable{
   
	private static final long serialVersionUID = 1L;
	
	public final static int PAGESIZE=3; 
	/**总条数*/
	private int total;
	/**总记录数*/
	private List rows;	
	@JsonIgnore
	/**下页的数据开始记录*/
	private int from;	
	@JsonIgnore
	/**结束的记录数*/
	private int size;
	@JsonIgnore
	/**当前页数*/
	private int nowpage;
	@JsonIgnore
	/**每页显示的条数*/
	private int pagesize;
	@JsonIgnore
    private Map<String, Object> condition; //查询条件

    @JsonIgnore
    private String sort = "seq";// 排序字段
    @JsonIgnore
    private String order = "asc";// asc，desc mybatis Order 关键字
    
	public PageInfo(){
		
	}
	
	public PageInfo(int nowpage,int pagesize){
		//计算当前页
		if(nowpage<1){
			this.nowpage=1;
		}else{
			this.nowpage=nowpage;
		}
		
		//记录每页显示的记录数  
		if(pagesize<1){
			this.pagesize=PAGESIZE;
		}else{
			this.pagesize=pagesize;
		}
		
		//计算开始的记录和结束的记录  
		this.from=(this.nowpage-1)*this.pagesize;
		this.size=this.pagesize;
	}
	
	public PageInfo(int nowpage,int pagesize,String order,String sort){
		
		this(nowpage,pagesize);
		// 排序字段，正序还是反序
		this.order=order;
		this.sort=sort;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public List getRows() {
		return rows;
	}

	public void setRows(List rows) {
		this.rows = rows;
	}

	public int getFrom() {
		return from;
	}

	public void setFrom(int from) {
		this.from = from;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public int getNowpage() {
		return nowpage;
	}

	public void setNowpage(int nowpage) {
		this.nowpage = nowpage;
	}

	public int getPagesize() {
		return pagesize;
	}

	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}

	public Map<String, Object> getCondition() {
		return condition;
	}

	public void setCondition(Map<String, Object> condition) {
		this.condition = condition;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}
	
	
}
